/*
 * SPDX-FileCopyrightText: 2024-2025 Carl Seifert
 * SPDX-FileCopyrightText: 2024-2025 TU Dresden
 * SPDX-License-Identifier: LGPL-2.1-only
 */

/**
 * @file
 * @ingroup unittests
 * @brief   Unit tests for CoAP option accessors
 * @author  Carl Seifert <carl.seifert1@mailbox.tu-dresden.de>
 */

#include <stdio.h>

#include "tests-unicoap.h"

#include "net/unicoap/options.h"
#include <errno.h>

static const char poem[] = "CoAP"

                           "In a world of bytes, where data flows,"
                           "Across the air, where no wire grows,"
                           "In the quiet hum of devices small,"
                           "Where sensors blink and data calls,"
                           "CoAP rises, light and clear,"
                           "A simple voice that all can hear."

                           "Lightweight, swift, it makes the call,"
                           "Requesting data, large or small."
                           "It sends a GET, it sends a POST,"
                           "Across the networks, coast to coast."
                           "So here's to networks small and grand,"
                           "Where CoAP's whispers gently land.";
/* - ChatGPT */

static void assert_options_data(const unicoap_options_t* options)
{
    /* In this order:
     * Uri-Path: actuators
     * Uri-Path: leds
     * Content-Format: JSON
     * Uri-Query: color=g
     * Accept: JSON
     */
    uint8_t option_data[] = {
        0xb9, 0x61, 0x63, 0x74, 0x75, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x04, 0x6c, 0x65, 0x64, 0x73,
        0x11, 0x32, 0x37, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x67, 0x21, 0x32
    };

    TEST_ASSERT_EQUAL_INT(options->option_count, 5);
    TEST_ASSERT_EQUAL_INT(unicoap_options_size(options), sizeof(option_data));
    _TEST_ASSERT_EQUAL_BYTES(unicoap_options_data(options), option_data, sizeof(option_data));
}

static void test_in_order(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 100);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "actuators"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "leds"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_content_format(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_query_string(&options, "color=g"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_accept(&options, UNICOAP_FORMAT_JSON), 0);

    assert_options_data(&options);
}

static void test_out_of_order(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 100);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_accept(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "actuators"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_query_string(&options, "color=g"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_content_format(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "leds"), 0);

    assert_options_data(&options);
}

static void test_idempotent(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 100);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_accept(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_accept(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "actuators"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_query_string(&options, "color=g"), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_content_format(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_content_format(&options, UNICOAP_FORMAT_TEXT), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set_content_format(&options, UNICOAP_FORMAT_JSON), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add_uri_path_component_string(&options, "leds"), 0);

    assert_options_data(&options);
}

static void _populate(unicoap_options_t* options)
{
    TEST_ASSERT_EQUAL_INT(unicoap_options_add(options, 50, (uint8_t*)poem, _UINT4_MAX + 1), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add(options, 12, (uint8_t*)poem, _UINT4_MAX), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add(options, 12, (uint8_t*)poem, _UINT4_MAX + 1), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add(options, 13, (uint8_t*)poem, _UINT4_MAX + 1), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set(options, 8, (uint8_t*)poem, _UINT12_MAX), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_add(options, 8, (uint8_t*)poem, _UINT12_MAX), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set(options, 10, (uint8_t*)poem, 200), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set(options, 2, (uint8_t*)poem, _UINT4_MAX + 1), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set(options, 70, (uint8_t*)poem, 1), 0);
    TEST_ASSERT_EQUAL_INT(unicoap_options_set(options, 1, (uint8_t*)poem, 1), 0);
}

static void test_extended_uint_shifts(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 900);
    _populate(&options);

    /* options blob, from nanoCoAP */
    static const uint8_t options_blob[] = {
        0x11, 0x43, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x6D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x0D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x2D, 0xBB, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x2C, 0x43, 0x6F, 0x41, 0x50, 0x49,
        0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x0D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E,
        0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E,
        0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xDD, 0x18, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49,
        0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xD1, 0x07, 0x43
    };

    TEST_ASSERT_EQUAL_INT(sizeof(options_blob), unicoap_options_size(&options));
    _TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
}

static void test_remove_leading(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 900);
    _populate(&options);

    TEST_ASSERT_EQUAL_INT(unicoap_options_remove(&options, 1), 0);

    /* options blob, from nanoCoAP */
    static const uint8_t options_blob[] = {
        0x2D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C,
        0x6D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C,
        0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77, 0x68, 0x65,
        0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73, 0x2C, 0x41,
        0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72, 0x2C, 0x20,
        0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65, 0x20, 0x67,
        0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69,
        0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76, 0x69, 0x63,
        0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72, 0x65, 0x20,
        0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x61,
        0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73, 0x2C, 0x43,
        0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69, 0x67, 0x68,
        0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41, 0x20, 0x73,
        0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74, 0x68, 0x61,
        0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61, 0x72, 0x2E,
        0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20, 0x73, 0x77,
        0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73, 0x20, 0x74,
        0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
        0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72, 0x67, 0x65,
        0x0D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C,
        0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77, 0x68, 0x65,
        0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73, 0x2C, 0x41,
        0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72, 0x2C, 0x20,
        0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65, 0x20, 0x67,
        0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69,
        0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76, 0x69, 0x63,
        0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72, 0x65, 0x20,
        0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x61,
        0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73, 0x2C, 0x43,
        0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69, 0x67, 0x68,
        0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41, 0x20, 0x73,
        0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74, 0x68, 0x61,
        0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61, 0x72, 0x2E,
        0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20, 0x73, 0x77,
        0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73, 0x20, 0x74,
        0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
        0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72, 0x67, 0x65,
        0x2D, 0xBB, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C,
        0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77, 0x68, 0x65,
        0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73, 0x2C, 0x41,
        0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72, 0x2C, 0x20,
        0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65, 0x20, 0x67,
        0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69,
        0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76, 0x69, 0x63,
        0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72, 0x65, 0x20,
        0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x61,
        0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73, 0x2C, 0x43,
        0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69, 0x67, 0x68,
        0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41, 0x20, 0x73,
        0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74, 0x68, 0x61,
        0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x2C, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20,
        0x61, 0x20, 0x77, 0x6F, 0x72, 0x0D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61,
        0x20, 0x77, 0x6F, 0x72, 0x6C, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61,
        0x20, 0x77, 0x6F, 0x72, 0x6C, 0xDD, 0x18, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20,
        0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xD1, 0x07, 0x43
    };

    TEST_ASSERT_EQUAL_INT(sizeof(options_blob), unicoap_options_size(&options));
    _TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
}

static void test_remove_trailing(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 900);
    _populate(&options);

    TEST_ASSERT_EQUAL_INT(unicoap_options_remove(&options, 70), 0);

    /* options blob, from nanoCoAP */
    static const uint8_t options_blob[] = {
        0x11, 0x43, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x6D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x0D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x2D, 0xBB, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x2C, 0x43, 0x6F, 0x41, 0x50, 0x49,
        0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x0D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E,
        0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E,
        0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xDD, 0x18, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49,
        0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C
    };

    TEST_ASSERT_EQUAL_INT(sizeof(options_blob), unicoap_options_size(&options));
    _TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
}

static void test_remove_multiple(void)
{
    UNICOAP_OPTIONS_ALLOC_STATIC(options, 900);
    _populate(&options);

    TEST_ASSERT_EQUAL_INT(unicoap_options_remove(&options, 12), 0);

    /* options blob, from nanoCoAP */
    static const uint8_t options_blob[] = {
        0x11, 0x43, 0x1D, 0x00, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x6D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x0D, 0xFF, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x68, 0x65, 0x61,
        0x72, 0x2E, 0x4C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x20,
        0x73, 0x77, 0x69, 0x66, 0x74, 0x2C, 0x20, 0x69, 0x74, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x73,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x52, 0x65, 0x71, 0x75, 0x65,
        0x73, 0x74, 0x69, 0x6E, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2C, 0x20, 0x6C, 0x61, 0x72,
        0x67, 0x65, 0x2D, 0xBB, 0x43, 0x6F, 0x41, 0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F,
        0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x2C, 0x20, 0x77,
        0x68, 0x65, 0x72, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6C, 0x6F, 0x77, 0x73,
        0x2C, 0x41, 0x63, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x69, 0x72,
        0x2C, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x77, 0x69, 0x72, 0x65,
        0x20, 0x67, 0x72, 0x6F, 0x77, 0x73, 0x2C, 0x49, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x71,
        0x75, 0x69, 0x65, 0x74, 0x20, 0x68, 0x75, 0x6D, 0x20, 0x6F, 0x66, 0x20, 0x64, 0x65, 0x76,
        0x69, 0x63, 0x65, 0x73, 0x20, 0x73, 0x6D, 0x61, 0x6C, 0x6C, 0x2C, 0x57, 0x68, 0x65, 0x72,
        0x65, 0x20, 0x73, 0x65, 0x6E, 0x73, 0x6F, 0x72, 0x73, 0x20, 0x62, 0x6C, 0x69, 0x6E, 0x6B,
        0x20, 0x61, 0x6E, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x73,
        0x2C, 0x43, 0x6F, 0x41, 0x50, 0x20, 0x72, 0x69, 0x73, 0x65, 0x73, 0x2C, 0x20, 0x6C, 0x69,
        0x67, 0x68, 0x74, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x41,
        0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x76, 0x6F, 0x69, 0x63, 0x65, 0x20, 0x74,
        0x68, 0x61, 0x74, 0x20, 0x61, 0x6C, 0x6C, 0x20, 0x63, 0x3D, 0x00, 0x43, 0x6F, 0x41, 0x50,
        0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xDD, 0x18, 0x00, 0x43, 0x6F, 0x41,
        0x50, 0x49, 0x6E, 0x20, 0x61, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0xD1, 0x07, 0x43
    };

    TEST_ASSERT_EQUAL_INT(sizeof(options_blob), unicoap_options_size(&options));
    _TEST_ASSERT_EQUAL_BYTES(options_blob, unicoap_options_data(&options), sizeof(options_blob));
}

Test* tests_unicoap_options(void)
{
    EMB_UNIT_TESTFIXTURES(fixtures){
        new_TestFixture(test_in_order),
        new_TestFixture(test_out_of_order),
        new_TestFixture(test_idempotent),
        new_TestFixture(test_extended_uint_shifts),
        new_TestFixture(test_remove_leading),
        new_TestFixture(test_remove_trailing),
        new_TestFixture(test_remove_multiple),
    };

    EMB_UNIT_TESTCALLER(test_unicoap, NULL, NULL, fixtures);

    return (Test*)&test_unicoap;
}
